var mySwiper = new Swiper('.swiper-container', {
	//			direction: 'vertical',c
	loop: true,
	// 如果需要分页器
	pagination: '.swiper-pagination',
	autoplay: 3000,
	autoplayDisableOnInteraction: false
})
// var mySwiper1 = new Swiper('.swiper-container1', {
// 	loop: true,
// 	// 如果需要分页器
// 	pagination: '.swiper-pagination',
// 	autoplay: 3000,
// 	autoplayDisableOnInteraction: false
// })
//阻止滑动scroll
//		var bg=document.getElementsByClassName("main")[0];
//		$(document).ready(function  () {
//			function stopScrolling(event){
//				event.preventDefault();
//			}
//			bg.addEventListener("touchmove",stopScrolling,false)
//		})
function changeIcon() {
	var token = selectByKey("like_token");
	console.log("token"+token);
	if(token) {
		var imgs = document.querySelector(".center");
		$(".center").attr("src", "statics/images/index1/Group.png");
		$.ajax({
			url: pathName + "/api/v1/member/cartNum",
			type: "GET",
			headers: {
				"Authorization": "Bearer " + token
			},
			success: function(data) {
				console.log(data.cartNum)
				if(data.cartNum > 0) {
					$(".cart").attr("src", "statics/images/individual/iconfont-gouwuche (1).png");

				}

			}
		})
	}

}
if(sessionStorage.getItem('orShowLayer') && sessionStorage.getItem('orShowLayer') == 1) {
	$(".markFloat").hide();
	$(".floatBox").show();
	$(".bg").css({
		"overflow": "auto"
	})
} else {
	$(".markFloat").show();

}
$(".close").on("click", function() {
	$(".markFloat").hide();
	$(".floatBox").show();
	$(".bg").css({
		"overflow": "auto"
	})
	sessionStorage.setItem('orShowLayer', 1);
})
var markFloat = document.querySelector(".markFloat");
$(".markFloat").on("click", function(e) {
	if(e.target == markFloat) {
		$(".markFloat").hide();
		$(".bg").css({
			"overflow": "auto"
		})
		sessionStorage.setItem('orShowLayer', 1);
	}

})
$(".detailed").on("click", function() {
	var index = $(".detailed").index($(this));
	if($(".name img").eq(index).attr("src") == "statics/images/index1/hollowHeart.png") {
		$(".name img").eq(index).attr("src", "statics/images/index1/heart.png");
	} else {
		$(".name img").eq(index).attr("src", "statics/images/index1/hollowHeart.png");
	}
})

$(".navItem").on("click", function() {
	var index = $(".navItem").index($(this))
	if(index == 0) {
		window.location.href = "views/online.html";
	} else if(index == 4) {
//		window.location.href = "views/cityWide/cityWide.html";
		window.location.href = "views/none.html";
	} else {
		window.location.href = "views/none.html";
	}
})

$(".single").on("click", function() {
	var index = $(".single").index($(this))
	if(index == 0) {
		window.location.href = "views/detail.html?id=368";
	} else if(index == 1) {
		window.location.href = "views/detail.html?id=355";
	} else if(index == 2) {
		window.location.href = "views/detail.html?id=405";
	} else if(index == 3) {
		window.location.href = "views/detail.html?id=378";
	}
})
$(".module").on("click", function() {
	var index = $(".module").index($(this))
	if(index == 0) {
		window.location.href = "views/school/school.html";
	} else {
		window.location.href = "views/school/school.html";
	}
})

//		$(".swiper-slide").on("click", function() {
//			window.location.href = "views/none.html";
//		})

window.onload = function() {
	changeIcon();
	var service = document.querySelector(".custom");
	var cart = document.querySelector(".cart");
	var center = document.querySelector(".center");
	var navItem = document.querySelectorAll(".navItem");
	var detailed = document.querySelectorAll(".detailed");
	var inputs = document.querySelector('header input');
	var form = document.querySelector("header form");
	Tap(service, function() {
		window.location.href = "views/service.html";
	});
	enterCar(cart);
	Tap(center, function() {
		if(selectByKey("like_token")) {
			window.location.href = 'views/personal/individual.html';
		} else {
			window.location.href = 'views/cityPartner/chooseLogin.html';
		}
	});
	form.onsubmit = function() {
		var searchName = inputs.value;
		localStorage.setItem("searchName", searchName);
	}

};

/*登录模块*/
function enterCar(value) {
	var token = selectByKey("like_token");
	var mask = document.querySelector(".markT");
	Tap(value, function() {
		if(token) {
			window.location.href = "views/trolley.html";
		} else {
			mask.style.display = "block";
		}
	});
	var sure = document.querySelector("#sureT");
	var cancle = document.querySelector("#cancleT");
	Tap(sure, function() {
		//		window.location.href = "views/personal/enter.html";
		window.location.href = "views/cityPartner/chooseLogin.html";
	});
	Tap(cancle, function() {
		mask.style.display = "none";
	});

}